Release 10.1A: OpenEdge Data Management:
SQL Development
Java snippet
The core of the stored procedure is the Java snippet. The snippet contains a sequence of Java statements. When it processes a
CREATE PROCEDUREstatement, OpenEdge SQL adds header and footer “wrapper” code to the Java snippet. This wrapper code:
- Declares a class with the name
username_procname_SP, whereusernameis the user name of the database connection that issued theCREATE PROCEDUREstatement andprocnameis the name supplied in theCREATE PROCEDUREstatement.- Declares a method within that class that includes the Java snippet. When an application calls the stored procedure, the SQL engine calls the Java virtual machine to invoke the method of the
username_procname_SPclass.Structure of stored procedures
There are two parts to any stored procedure:
A simple stored procedure requires the procedure name in the specification and a statement requiring no parameters in the body. Example 9–2 assumes the existence of a table named
HellowWorld, and inserts a quoted string into that table.
Subsequently, you can execute the procedure shown in Example 9–3.
The procedure specification can also contain other clauses.
Parameter declarations specify the names and types of parameters that the calling application will pass and receive from the procedure. Parameters can be input, output, or both.
The procedure result set declaration details the names and types of fields in a result set the procedure generates. The result set is a set of rows that contain data generated by the procedure. If a procedure retrieves rows from a database table, for instance, it can store the rows in a result set for access by applications and other procedures. The names specified in the result-set declaration are not used within the stored procedure body. Instead, methods of the OpenEdge SQL Java classes refer to fields in the result set by ordinal number, not by name.
The import clause specifies which packages the procedure needs from the Java core API. By default, the Java compiler imports the
java.langpackage. TheIMPORTclause must list any other packages the procedure uses. OpenEdge SQL automatically imports the packages it requires.Example 9–4 shows a more complex procedure specification that contains these elements.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |